package com.neusoft.elm;

import java.util.Scanner;

import com.neusoft.elm.po.Admin;
import com.neusoft.elm.view.AdminView;
import com.neusoft.elm.view.AdminViewImpl;
import com.neusoft.elm.view.BusinessView;
import com.neusoft.elm.view.BusinessViewImpl;

//管理员业务线
public class ElmAdminEntry {
	
	public void work() {
		Scanner input=new Scanner(System.in);//接受用户输入
		System.out.println("-----------------------------------------------------------------");
        System.out.println("|\t\t\t 饿了么后台管理系统  \t\t\t|");
        System.out.println("-----------------------------------------------------------------");
		AdminView adminView=new AdminViewImpl();
		Admin admin=adminView.login();
		BusinessView businessView=new BusinessViewImpl();
		  //登录
		if(admin!=null) {
			int menu=0;
			//输出子菜单
			while(menu!=5) {
			System.out.println("\n========= 1.所有商家列表=2.搜索商家=3.新建商家=4.删除商家=5.退出系统 =========\n");
			//只要不选择5，就让用户再回到主菜单
			System.out.println("请输入你的选择：\n");
			menu=input.nextInt();
			switch(menu) {
			case 1://商家列表
				businessView.listBusinessAll();
				break;
			case 2://搜索商家
				businessView.listBusiness();
		        break;
			case 3://新建商家
				businessView.createBusiness();
				break;
			case 4://删除商家
				businessView.removeBusiness();
				break;
			case 5:
				System.out.println("------------------------欢迎下次光临饿了么后台管理系统-----------------------");
				break;
			default:
				System.out.println("没有这个选项！\n");
			}
			
			
			
			}
		}else {
			System.out.println("\n管理员密码输入错误\n");
		}
		 input.close();
	}
	//写一个入口方法来执行work方法
	public static void main(String[] args) {
		new ElmAdminEntry().work(); 
	}

}
